<template>
  <div id="app">
    <NavBar
      :title="$route.meta.title"
      left-arrow
      @click-left="onClickLeft"
    >
    </NavBar>
    <RouterView class="wrapper" />
  </div>
</template>
<script>
import { NavBar } from 'vant'
import emitter from '@/hybrid/emitter'
export default {
  components: { NavBar },
  created () {
    emitter.on('fullter_set_token', (token) => {
      this.$store.commit('setToken', token)
    })
  },
  methods: {
    onClickLeft () {
      if (this.$route.path === '/user') {
        // 调用flutter的返回
        window.FlutterBack && window.FlutterBack.postMessage('返回操作')
      } else {
        this.$router.back()
      }
    }
  }
}
</script>
